package com.wtwd.campus.receiver;

import com.wtwd.campus.entity.MqGeneralValueResult;
import com.wtwd.campus.service.IRMFeignClientService;
import com.wtwd.campus.service.InjectFeignService;
import org.springframework.beans.factory.annotation.Autowired;

public class UploadLowBatteryWarningReceiver implements Receiver {
    @Autowired
    private IRMFeignClientService irmFeignClientService;

    @Override
    public String parseMessage(String data) {
        //        String str = data.substring(0, data.length() - 1); //将指令末尾的#截取掉
        //分割字符串获取指令信息
        String[] split = data.split(",");
        String imei = split[1];
        String messageType = split[2];
        String commandNumber = split[3];
        String status = split[5];//状态，具体协议未说明
        String date = split[4];//日月年
        MqGeneralValueResult mqGeneralValueResult = new MqGeneralValueResult();
        mqGeneralValueResult.setImei(imei);
        mqGeneralValueResult.setCommandNumber(commandNumber);
        mqGeneralValueResult.setDeviceDate(date);
        mqGeneralValueResult.setDeviceTime(commandNumber);
        mqGeneralValueResult.setDeviceStatus(status);
        InjectFeignService.getIrmFeignClientService().upLowBatteryMessage(mqGeneralValueResult);
        return imei;
    }
}
